﻿using HKB.Common;
using HKB.Web;
using HKB.Web.Shop;
using System;
using System.Data;
using System.Text;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

public partial class Admin_ShowProduct : Shop, IRequiresSessionState
{
    protected int ShopID = 0;
    protected new int SkinID = 0;
    protected int ClassID = 0;
    protected string StyleSkin = "";
    protected decimal Price = 0m;
    protected string PriceName = "";
    protected decimal CurrentPrice = 0m;
    protected string ProductType = "";
    protected string Guarantee = "";
    protected string NeedInvoice = "";
    protected string PayType = "";
    protected string ProductNum = "0";
    protected string ProductSellNum = "";
    protected string Hits = "0";
    protected string ProductIntro = "";
    protected string StartDate = "";
    protected string Stocks = "0";
    protected string ProductPlace = "";
    protected string ProductStandard = "";
    protected string DeliverPayType = "";
    protected string ProductName = "";
    protected string OurrentPrice = "0";
    protected string ProductImageUrl = "";
    protected string PUnit = "";
    protected string EnableSale = "";
    protected string EnableSingleSell = "";
    protected string AutoPostBack = "";
    protected string UploadFiles = "";
    protected int LeftTime = 0;
    protected string ProductSmallImageUrl = "";
    protected string Story;
    protected string ProductModel = "";
    protected int SaleCrediet = 0;
    protected int BuyCrediet = 0;
    protected string SalerName = "";
    protected DateTime BeginDate;
    protected DateTime EndDate;
    protected DateTime UpdateTime;
    protected DateTime RegTime;
    protected string MobilePhone = "";
    protected string OrderNum = "";
    protected bool IntegraUse = false;
    protected int BuyTimes = 0;
    protected string ContantMe = "";
    protected string strColor = "";
    protected string strSize = "";
    protected string ChangeBigImg = "";
    protected string Deliver = "block";
    public string ShopImageUrl = "";
    public string SmallImageUrl;
    public string Taobaowangwang = string.Empty;
    public string OICQ = string.Empty;
    protected string HasParameter = "0";
    public string prc_sp_valueDetail = "";
    public string prc_sp_title = "";
    public string IntProductType = "";
    public string showDeliverPayTypeDetail = "";
    public string CustomPrice = "";
    private StringBuilder TeamBuyList;
    private StringBuilder TeamBuyPrice;
    private StringBuilder AuctionPrice;
    private Shop_Product _shop_product = null;
    private int _productID = -1;
    private int _salerID = -1;
    public int EveryPageCount = 1;
    private int _CommentPageCount = -1;
    private int _buyRecordCount = -1;
    public int EveryPageSizeForBuyRecord = 2;
    private string _currentPage = "0";
    public int EveryPageForMessage = 2;
    private int _messageCount = -1;
    protected bool showShopInfoPower = false;
    private string showProType = "";
   
    protected string description
    {
        get;
        set;
    }
    protected string keyword
    {
        get;
        set;
    }
    protected Shop_Product m_shop_product
    {
        get
        {
            Shop_Product shop_product;
            if (this._shop_product == null)
            {
                this._shop_product = new Shop_Product(this.conn);
                shop_product = this._shop_product;
            }
            else
            {
                shop_product = this._shop_product;
            }
            return shop_product;
        }
    }
    public int ProductID
    {
        get
        {
            int result;
            if (Fetch.Get("productid") == string.Empty)
            {
                result = 0;
            }
            else
            {
                if (int.TryParse(Fetch.Get("productid"), out this._productID))
                {
                    result = this._productID;
                }
                else
                {
                    result = 0;
                }
            }
            return result;
        }
        set
        {
            this._productID = value;
        }
    }
    public int SalerID
    {
        get
        {
            int salerID;
            if (this._salerID != -1)
            {
                salerID = this._salerID;
            }
            else
            {
                DataTable dataTable = this.conn.GetDataTable("select SalerID from HLShop_Product where ProductID=" + this.ProductID);
                if (dataTable != null && dataTable.Rows.Count > 0)
                {
                    this._salerID = int.Parse(dataTable.Rows[0]["SalerID"].ToString());
                }
                dataTable.Dispose();
                salerID = this._salerID;
            }
            return salerID;
        }
        set
        {
            this._salerID = value;
        }
    }
    public int CommentPageCount
    {
        get
        {
            int commentPageCount;
            if (this._CommentPageCount != -1)
            {
                commentPageCount = this._CommentPageCount;
            }
            else
            {
                IDbDataParameter[] parameters = new IDbDataParameter[]
				{
					this.conn.CreateParameter("@ProductID", DbType.Int32, this.ProductID),
					this.conn.CreateParameter("@SalerID", DbType.Int32, this.SalerID)
				};
                this._CommentPageCount = this.conn.ExecuteCount("select count(*) \r\n                            from HLMall_Credit as a \r\n                            join HLShop_OrderItem as b on\r\n                            a.OrderFormNum=b.OrderFormNum and b.ProductID=@ProductID and a.ValuerID<>@SalerID " + this.QueString() + " join HL_UserInfo as d\r\n                            on d.UserID = a.ValuerID\r\n                            join HL_User as c\r\n                            on c.UserID=a.ValuerID and c.IsLocked=0", parameters);
                commentPageCount = this._CommentPageCount;
            }
            return commentPageCount;
        }
    }
    public int BuyRecordCount
    {
        get
        {
            int buyRecordCount;
            if (this._buyRecordCount != -1)
            {
                buyRecordCount = this._buyRecordCount;
            }
            else
            {
                IDbDataParameter[] parameters = new IDbDataParameter[]
				{
					this.conn.CreateParameter("@ProductID", DbType.Int32, this.ProductID)
				};
                this._buyRecordCount = this.conn.ExecuteCount("select count(*)\r\n                                            from HLShop_Order as a\r\n                                            join  HLShop_OrderItem as b\r\n                                            on a.OrderFormID=b.OrderFormID and a.PayStatus=1  \r\n                                            join HLShop_Product as c \r\n                                            on   b.ProductID=c.ProductID and c.ProductID=@ProductID \r\n                                            join HLShop_DeliverItem as d \r\n                                            on a.OrderFormID=d.OrderID and d.Received=1", parameters);
                buyRecordCount = this._buyRecordCount;
            }
            return buyRecordCount;
        }
    }
    public string SelectType
    {
        get
        {
            string result;
            if (this.GoodComment.Checked)
            {
                result = "1";
            }
            else
            {
                if (this.MiddleComment.Checked)
                {
                    result = "0";
                }
                else
                {
                    if (this.BadComment.Checked)
                    {
                        result = "-1";
                    }
                    else
                    {
                        result = "2";
                    }
                }
            }
            return result;
        }
    }
    public string CurrentPage
    {
        get
        {
            string result;
            if (this._currentPage != "0")
            {
                result = this._currentPage;
            }
            else
            {
                string s = this.currentPage.InnerText.Trim();
                int num = 0;
                if (int.TryParse(s, out num))
                {
                    this._currentPage = num.ToString();
                }
                else
                {
                    this._currentPage = "1";
                }
                result = this._currentPage;
            }
            return result;
        }
        set
        {
            this._currentPage = value;
        }
    }
    public string ProvinceAndCity
    {
        get;
        set;
    }
    public int MessageCount
    {
        get
        {
            int messageCount;
            if (this._messageCount != -1)
            {
                messageCount = this._messageCount;
            }
            else
            {
                IDbDataParameter[] parameters = new IDbDataParameter[]
				{
					this.conn.CreateParameter("@ProductID", DbType.Int32, this.ProductID)
				};
                this._messageCount = this.conn.ExecuteCount("select count(*) from  dbo.HLShop_Message where M_ProductID=@ProductID and M_UserType='buyer'", parameters);
                messageCount = this._messageCount;
            }
            return messageCount;
        }
    }
    public string ShopName
    {
        get;
        set;
    }
    public string ShopAddress
    {
        get;
        set;
    }
    public string ShopCity
    {
        get;
        set;
    }
    public bool ShowShopInfoPower
    {
        get
        {
            return this.showShopInfoPower;
        }
        set
        {
            this.showShopInfoPower = value;
        }
    }
    public new string ShowProType
    {
        get
        {
            return this.showProType;
        }
        set
        {
            this.showProType = value;
        }
    }
    protected string logstr
    {
        get
        {
            string result;
            if (base.user.UserID <= 0)
            {
                result = string.Concat(new string[]
				{
					"window.location.href = '",
					this.InstallDir,
					"Passport/Login.aspx?ComeUrl=",
					base.Server.UrlEncode(Fetch.CurrentUrl),
					"';return;"
				});
            }
            else
            {
                result = "";
            }
            return result;
        }
    }
    protected DefaultProfile profile
    {
        get
        {
            return (DefaultProfile)this.Context.Profile;
        }
    }
    protected global_asax applicationInstance
    {
        get
        {
            return (global_asax)this.Context.ApplicationInstance;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (this.SalerID == -1)
        {
            this.WriteErrMsg("", Language.Get("Common/NoData"), "");
        }
        if (!this.Page.IsPostBack)
        {
            if (this.conn.ExecuteCount("select count(*) from HLShop_Product where DateDiff(s,EndDate,getdate())<0 and ProductID=" + this.ProductID) <= 0)
            {
                this.WriteSuccessMsg("", "该商品已到期!", "/ProductList.aspx");
            }
            else
            {
                this.GetProductDetail();
                this.BindEvaluation();
                this.SetCommetnLink();
                this.SetSelectForComment();
                this.GetBuyRecord();
                this.GetProductByBuyTimes();
                this.GetFavouritePro();
                this.GetSalerDetail();
                this.GetMessage();
                this.GetProAndShopFav();
                this.ShowMessage();
                this.Page.Title = this.ProductName + " -- " + this.config["SiteName"];
                this.ShowTopShopInfo(this.ShopID);
                this.ShowShopClass(this.ShopID);
                base.ClientRelation(this.ShopID, "browse");
                this.OutStockPower(this.ShopID);
            }
        }
    }
    public void SubmitMsg(object sender, EventArgs e)
    {
        if (base.user.UserID < 1)
        {
            this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "msg", "<script>alert('');</script>");
        }
        else
        {
            if (base.user.UserID == this.SalerID)
            {
                this.err_tips.Text = "不能给自己留言！";
            }
            else
            {
                IDbDataParameter[] parameters = new IDbDataParameter[]
				{
					this.conn.CreateParameter("@ProductID", DbType.Int32, this.ProductID),
					this.conn.CreateParameter("@Content", DbType.String, this.Message_Content.Value)
				};
                if (this.Message_Content.Value.Length > 400)
                {
                    this.err_tips.Text = "内容字数不能超过400！";
                }
                else
                {
                    if (!this.CheckValidateCode(this.CheckCode.Value))
                    {
                        this.err_tips.Text = Language.GetAdminMsg("Login/CodeErr");
                    }
                    else
                    {
                        this.err_tips.Text = "";
                        if (base.user.UserID != this.SalerID)
                        {
                            if (this.conn.Execute(string.Concat(new object[]
							{
								"INSERT INTO [dbo].[HLShop_Message] ([M_ReplayID],[M_Type],[M_ProductID],[M_ShopID],[M_DateTime],[M_UserID],[M_Status],[M_Content],[M_ReceiverID],[M_SenderName],[M_ReceiverName],[M_UserType])\r\n                       VALUES(0,0,@ProductID,0,GETDATE(),",
								base.user.UserID,
								",0,@Content,",
								this.SalerID,
								",'",
								base.user.UserName,
								"','",
								this.HiddenField1.Value,
								"','buyer')"
							}), parameters) < 1)
                            {
                                this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "msg", "<script>alert('发表失败！');</script>");
                            }
                            else
                            {
                                this.Message_Content.Value = "";
                                this.CheckCode.Value = "";
                                this.GetMessage();
                            }
                        }
                    }
                }
            }
        }
    }
    private void ShowMessage()
    {
        if (base.user.CheckUserLogin())
        {
            this.Message_Panel2.Visible = true;
            this.Message_Panel1.Visible = false;
        }
        else
        {
            this.Message_Panel1.Visible = true;
            this.Message_Panel2.Visible = false;
        }
    }
    public void ShowShopClass(int Shop_ID)
    {
        if (Shop_ID > 0)
        {
            string str = "select a.ShopProductClassID,ShopProductClassName from HLShop_ProductLikeCategory as a \r\n                            join HLShop_Product as b on a.shopID=b.shopID join HLShop_Class as c on c.ClassID=b.ClassID ";
            string str2 = " and a.shopID=" + Shop_ID;
            string str3 = " group by a.ShopProductClassID,a.ShopProductClassName order by a.ShopProductClassID desc";
            string sql = str + str2 + str3;
            this.DataClassList.DataSource = this.conn.GetDataTable(sql);
            this.DataClassList.DataBind();
        }
    }
    private void GetProAndShopFav()
    {
        IDbDataParameter[] parameters = new IDbDataParameter[]
		{
			this.conn.CreateParameter("@ProductID", DbType.Int32, this.ProductID)
		};
        DataTable dataTable = this.conn.GetDataTable("select COUNT(*) as ProFav from [HLShop_MyFavourite] where F_Type=0 and F_ProductID=@ProductID ", parameters);
        if (dataTable != null && dataTable.Rows.Count > 0)
        {
            this.ltrProductFav.Text = dataTable.Rows[0]["ProFav"].ToString();
        }
    }
    private void GetMessage()
    {
        IDbDataParameter dbDataParameter = this.conn.CreateParameter("@ProductID", DbType.Int32, this.ProductID);
        string commandText = "select top " + this.EveryPageForMessage + " * from  dbo.HLShop_Message where M_ProductID=@ProductID and M_UserType='buyer' ORDER BY  M_DateTime Desc";
        this.Repeater3.DataSource = this.conn.GetDataTable(commandText, new IDbDataParameter[]
		{
			dbDataParameter
		});
        this.Repeater3.DataBind();
    }
    private void GetSalerDetail()
    {
        IDbDataParameter dbDataParameter = this.conn.CreateParameter("@SalerID", DbType.Int32, this.SalerID);
        DataTable dataTable = this.conn.GetDataTable("select \r\n                        (select ShopImageUrl from HLShop_Shop where ShopOwnerID=@SalerID) as ShopImageUrl,\r\n                        (select ShopName from HLShop_Shop where ShopOwnerID=@SalerID) as ShopName,\r\n                        (select ShopRegDate from HLShop_Shop where ShopOwnerID=@SalerID and ShopStatus=1) as RegDate,\r\n                        (select Province+'&nbsp'+City from HLShop_Shop where ShopOwnerID=@SalerID) as ProAndCity,\r\n                        (select COUNT(*) from [HLShop_MyFavourite] \r\n                        where F_ShopID in (select ShopID  from HLShop_Shop where ShopOwnerID=@SalerID)) as FavouriteCou, \r\n                        (select COUNT(*) from HLShop_Product where EndDate>=GETDATE()\r\n                        and EnableSale=1 and Stocks>0 and EnableSingleSell=1 and SalerID=@SalerID) as ProCount,\r\n                        (select COUNT(*) from dbo.HLMall_Credit where JustSBCredit=0 and ByValuerID=@SalerID) as totalComm,\r\n                        (select COUNT(*) from dbo.HLMall_Credit where CreditScore=1 and JustSBCredit=0 and ByValuerID=@SalerID) as GoodComm,\r\n                        (select COUNT(*) from dbo.HLMall_Credit where CreditScore=0 and JustSBCredit=0 and ByValuerID=@SalerID) as MiddleComm,\r\n                        (select COUNT(*) from dbo.HLMall_Credit where CreditScore=-1 and JustSBCredit=0 and ByValuerID=@SalerID) as BadComm,\r\n                        (select ShopAddress from HLShop_Shop where ShopOwnerID=@SalerID) as Address,\r\n                        (select City from HLShop_Shop where ShopOwnerID=@SalerID) as City ", new IDbDataParameter[]
		{
			dbDataParameter
		});
        if (dataTable != null && dataTable.Rows.Count > 0)
        {
            this.ShopImageUrl = dataTable.Rows[0]["ShopImageUrl"].ToString();
            this.ProvinceAndCity = dataTable.Rows[0]["ProAndCity"].ToString();
            if (this.ProvinceAndCity == "")
            {
                this.ProvinceAndCity = "&nbsp;";
            }
            this.ltrShopRegDate.Text = dataTable.Rows[0]["RegDate"].ToString();
            if (this.ltrShopRegDate.Text == "")
            {
                this.ltrShopRegDate.Text = "未知";
            }
            this.ltrFavouriteCou.Text = dataTable.Rows[0]["FavouriteCou"].ToString();
            this.ltrProCount.Text = dataTable.Rows[0]["ProCount"].ToString();
            int num = Convert.ToInt32(dataTable.Rows[0]["totalComm"]);
            int num2 = Convert.ToInt32(dataTable.Rows[0]["GoodComm"]);
            int num3 = Convert.ToInt32(dataTable.Rows[0]["MiddleComm"]);
            int num4 = Convert.ToInt32(dataTable.Rows[0]["BadComm"]);
            this.ShopName = dataTable.Rows[0]["ShopName"].ToString();
            this.ShopAddress = dataTable.Rows[0]["Address"].ToString();
            this.ShopCity = dataTable.Rows[0]["City"].ToString();
            if (num != 0)
            {
                this.ltrGoodPercent.Text = this.GetPercent(((float)num2 / (float)num * 100f).ToString());
            }
            else
            {
                this.ltrGoodPercent.Text = "0%";
            }
        }
    }
    private string GetPercent(string pointValue)
    {
        string result;
        if (string.IsNullOrEmpty(pointValue))
        {
            result = "0%";
        }
        else
        {
            if (pointValue.IndexOf('.') > 0)
            {
                if (pointValue.Substring(pointValue.IndexOf('.') + 1).Length > 2)
                {
                    if (Convert.ToInt32(pointValue.Substring(pointValue.IndexOf('.') + 3, 1)) >= 5)
                    {
                        pointValue = (Convert.ToDouble(pointValue) + 0.01).ToString().Remove(pointValue.IndexOf('.') + 3);
                    }
                    else
                    {
                        pointValue = pointValue.Remove(pointValue.IndexOf('.') + 3);
                    }
                }
            }
            result = pointValue + "%";
        }
        return result;
    }
    private void GetProductByBuyTimes()
    {
        if (this.SalerID != -1)
        {
            string str = "(select sum(Quantity) from HLShop_OrderItem as c join HLShop_Order as d on c.ProductID=b.ProductID and  c.OrderFormNum=d.OrderFormNum  and d.Status=2) as BuyTimes,";
            string text = " a.ProductID,a.ProductName,a.StandPrice,a.PUnit," + str + "a.ProductImageUrl,a.Stocks,a.ShopID,a.SalerID,a.ProductPlace,a.ProductNum,a.ClassID,b.ImgPath1";
            string text2 = "select d.ProductID from HLShop_Order as c,HLShop_OrderItem as d where DateDiff(MM,c.InputTime,getdate())=0 and c.OrderFormID=d.OrderFormID group by d.ProductID";
            string text3 = string.Concat(new object[]
			{
				"a.EndDate>=GETDATE() and a.EnableSale=1 and a.Stocks>0 and a.EnableSingleSell=1  and a.ProductID=b.ProductID and a.ProductID in (",
				text2,
				") and a.ShopID=",
				this.ShopID
			});
            string sql = string.Concat(new string[]
			{
				"select top 10 * from (select ",
				text,
				" from  HLShop_Product as a,dbo.HLShop_ProductImg as b where ",
				text3,
				") as t order by BuyTimes Desc"
			});
            DataTable dataTable = this.conn.GetDataTable(sql);
            this.Repeater1.DataSource = dataTable;
            this.Repeater1.DataBind();
            dataTable.Dispose();
        }
    }
    private void GetFavouritePro()
    {
        if (this.SalerID != -1)
        {
            DataTable dataTable = this.conn.GetDataTable("select top 10 a.*,b.ImgPath1,(select COUNT(*) from [HLShop_MyFavourite] where F_Type=0 and F_ProductID=a.ProductID) as Num \r\n                                    from  HLShop_Product as a\r\n                                    join dbo.HLShop_ProductImg as b\r\n                                    on a.EndDate>=GETDATE() and a.EnableSale=1 and a.Stocks>0 and a.EnableSingleSell=1  and a.SalerID=" + this.SalerID + "  and a.ProductID=b.ProductID\r\n                                    order by Num Desc");
            this.Repeater2.DataSource = dataTable;
            this.Repeater2.DataBind();
            dataTable.Dispose();
        }
    }
    private void GetGuige(string guigeTitle, string guigeValue)
    {
        if (!string.IsNullOrEmpty(guigeTitle) && !string.IsNullOrEmpty(guigeValue) && guigeTitle.Length >= 1 && guigeValue.Length >= 1)
        {
            string[] array = guigeValue.Split(new string[]
			{
				"|"
			}, StringSplitOptions.RemoveEmptyEntries);
            string text = "";
            int num = 2;
            string[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                string text2 = array2[i];
                string[] array3 = text2.Split(new string[]
				{
					":"
				}, StringSplitOptions.RemoveEmptyEntries);
                string[] array4 = array3[1].Trim().Split(new string[]
				{
					","
				}, StringSplitOptions.RemoveEmptyEntries);
                if (array3[0] == "1")
                {
                    int num2 = array3[1].IndexOf("$");
                    if (num2 > 0)
                    {
                        int num3 = num2;
                        int num4 = num2;
                        if (num3 + 1 > 0)
                        {
                            num4 = num3 + 1;
                        }
                        string text3 = array3[1].Substring(num3);
                        if (num4 - 1 > 0)
                        {
                            num4--;
                        }
                        string text4 = array3[1].Substring(0, num4);
                        array3[1] = text4;
                    }
                }
                string text5 = array3[1].Trim(new char[]
				{
					','
				});
                if (text5 == "")
                {
                    text5 = "0";
                }
                DataTable dataTable = this.conn.GetDataTable(string.Concat(new string[]
				{
					"select a.*,b.sp_name from dbo.HLshop_spec_value as a\r\n                                                  join HLShop_spec as b\r\n                                                  on a.sp_id=b.sp_id and a.sp_id=",
					array3[0],
					" and a.sp_value_id in (",
					text5,
					")"
				}));
                if (dataTable != null && dataTable.Rows.Count > 0)
                {
                    string text6 = dataTable.Rows[0]["sp_name"].ToString();
                    if (text6.Trim() == "颜色")
                    {
                        StringBuilder stringBuilder = new StringBuilder("");
                        stringBuilder.Append("<dl  ctype='guig'><DT>颜色：</DT><dd><ul nctyle='ul_sign'>");
                        foreach (DataRow dataRow in dataTable.Rows)
                        {
                            string arg = dataRow["sp_value_id"].ToString();
                            string arg2 = dataRow["sp_value_name"].ToString();
                            string arg3 = dataRow["sp_value_image"].ToString();
                            stringBuilder.AppendFormat("<LI class=sp-img><A  style='BACKGROUND-IMAGE:url({0})' \r\n                          class=nc-zoom-gallery title='{1}' ctype='{2}' onClick='selectSpec(1, this)'   href='javascript:' >{1}<I></I></A></LI>", arg3, arg2, arg);
                        }
                        stringBuilder.Append("</ul></dd></dl>");
                        text += stringBuilder.ToString();
                    }
                    else
                    {
                        StringBuilder stringBuilder = new StringBuilder("");
                        stringBuilder.Append("<dl  ctype='guig'><DT>" + text6 + "：</DT><DD><UL nctyle='ul_sign'>");
                        foreach (DataRow dataRow in dataTable.Rows)
                        {
                            string text7 = dataRow["sp_value_id"].ToString();
                            string text8 = dataRow["sp_value_name"].ToString();
                            stringBuilder.Append(string.Concat(new object[]
							{
								"<LI class=sp-txt><A onClick='selectSpec(",
								num,
								", this)'  ctype='",
								text7,
								"'  href='javascript:void(0)'>",
								text8,
								"<I></I></A></LI> "
							}));
                        }
                        stringBuilder.Append("</ul></dd></dl>");
                        text += stringBuilder.ToString();
                    }
                }
                num++;
            }
            this.ltrGuige.Text = text;
        }
    }
    private void GetProductDetail()
    {
        HoWaveProduct hoWaveProduct = new HoWaveProduct(this.conn);
        DataTable productByID = hoWaveProduct.GetProductByID(this.ProductID);
        if (productByID == null || productByID.Rows.Count < 1)
        {
            this.WriteErrMsg("", Language.Get("Common/NoData"), "");
        }
        DataRow dataRow = productByID.Rows[0];
        this.BingProductAttribute(dataRow["Attributes"].ToString());
        this.ltrProductIntro.Text = dataRow["ProductIntro"].ToString();
        this.wish_product_name.InnerHtml = (this.ltrProductName.Text = dataRow["ProductName"].ToString());
        this.GetGuige(dataRow["prc_sp_title"].ToString(), dataRow["prc_sp_value"].ToString());
        this.description = string.Format("<meta name=\"description\" content=\"{0}\" />", (dataRow["Description"] != DBNull.Value) ? dataRow["Description"].ToString() : "");
        this.keyword = string.Format("<meta name=\"keywords\" content=\"{0}\" />", (dataRow["Keyword"] != DBNull.Value) ? dataRow["Keyword"].ToString() : "");
        if (this.ProductID < 1)
        {
            this.WriteErrMsg("", Language.Get("Common/NotData"), "");
        }
        if (productByID.Rows.Count > 0)
        {
            dataRow = productByID.Rows[0];
        }
        else
        {
            this.WriteErrMsg("", Language.Get("Common/NotData"), "");
        }
        this.SalerID = Convert.ToInt32(dataRow["SalerID"]);
        bool flag = Convert.ToBoolean(dataRow["IsApprove"]);
        DateTime dateTime = Convert.ToDateTime(dataRow["BeginDate"].ToString());
        if (this.SalerID != base.user.UserID)
        {
            string groupPower = base.user.GetGroupPower("GroupPower");
            if (groupPower.Contains("allowproduceApproval"))
            {
                if (!flag)
                {
                    this.WriteErrMsg("", Language.Get("Common/NoApprove"), "");
                }
            }
        }
        else
        {
            if (!flag)
            {
                this.WriteErrMsg("", "该商品还处在审核期间!", "");
            }
        }
        this.EnableSale = dataRow["EnableSale"].ToString().ToLower();
        this.EnableSingleSell = dataRow["EnableSingleSell"].ToString().ToLower();
        this.Stocks = dataRow["Stocks"].ToString();
        this.hfStocks.Value = this.Stocks;
        this.AutoPostBack = dataRow["AutoPostBack"].ToString();
        if (Convert.DBNull != dataRow["LeftTime"])
        {
            this.LeftTime = Convert.ToInt32(dataRow["LeftTime"]);
        }
        this.ProductName = dataRow["ProductName"].ToString();
        this.ProductType = dataRow["ProductType"].ToString();
        this.IntProductType = dataRow["ProductType"].ToString();
        this.HiddenField3.Value = this.IntProductType.ToString();
        this.prc_sp_valueDetail = (string.IsNullOrEmpty(dataRow["prc_sp_valueDetail"].ToString()) ? "[]" : dataRow["prc_sp_valueDetail"].ToString());
        this.prc_sp_title = dataRow["prc_sp_title"].ToString();
        this.ProductSmallImageUrl = dataRow["ProductSmallImageUrl"].ToString();
        this.ClassID = Convert.ToInt32(dataRow["ClassID"]);
        this.ShopID = Convert.ToInt32(dataRow["ShopID"]);
        this.PayType = dataRow["PayType"].ToString();
        this.ProductNum = dataRow["Stocks"].ToString();
        this.PUnit = dataRow["PUnit"].ToString();
        this.Hits = dataRow["Hits"].ToString();
        dateTime = Convert.ToDateTime(dataRow["BeginDate"]);
        this.EndDate = Convert.ToDateTime(dataRow["EndDate"]);
        this.ProductStandard = dataRow["ProductStandard"].ToString();
        this.OrderNum = dataRow["OrderNum"].ToString();
        this.DeliverPayType = dataRow["DeliverPayType"].ToString();
        this.UploadFiles = dataRow["UploadFiles"].ToString();
        this.strColor = dataRow["Color"].ToString();
        this.IntegraUse = (!(dataRow["IntegraUse"] is DBNull) && Convert.ToBoolean(dataRow["IntegraUse"]));
        if (!string.IsNullOrEmpty(dataRow["CustomPrice"].ToString()))
        {
            this.CustomPrice = dataRow["CustomPrice"].ToString();
        }
        else
        {
            this.CustomPriceDIV.Visible = false;
        }
        if (Convert.DBNull != dataRow["CurrentPrice"])
        {
            this.CurrentPrice = Convert.ToDecimal(dataRow["CurrentPrice"]);
        }
        string sql = "select sum(Quantity) from HLShop_OrderItem as c join HLShop_Order as d on c.ProductID=" + this.ProductID + " and  c.OrderFormNum=d.OrderFormNum  and d.Status=2";
        DataTable dataTable = this.conn.GetDataTable(sql);
        if (dataTable != null)
        {
            if (dataTable.Rows.Count > 0)
            {
                if (dataTable.Rows[0][0] != DBNull.Value)
                {
                    this.BuyTimes = Convert.ToInt32(dataTable.Rows[0][0]);
                }
            }
        }
        if (Convert.DBNull != dataRow["UpdateTime"])
        {
            this.UpdateTime = Convert.ToDateTime(dataRow["UpdateTime"]);
        }
        else
        {
            this.UpdateTime = dateTime;
        }
        this.ProductType = TextFormat.GetProductType(this.ProductType);
        bool flag2 = false;
        if (!string.IsNullOrEmpty(dataRow["BeginDate"].ToString()))
        {
            if (Convert.ToDateTime(dataRow["BeginDate"]) > DateTime.Now)
            {
                flag2 = true;
                this.WaitingImage.Visible = true;
                this.BuyImage.Visible = false;
                this.ShoppingCartImage.Visible = false;
            }
        }
        DateTime now = DateTime.Now;
        this.ShowProType = dataRow["ProductType"].ToString();
        switch (int.Parse(dataRow["ProductType"].ToString()))
        {
            case 1:
                this.ltrMarket.Visible = true;
                this.HiddenField2.Value = dataRow["StandPrice"].ToString();
                this.ltrMarket.Text = "<dl ctype='market' class='nc-detail-price'><dt>一&nbsp;口&nbsp;价：</dt><dd><strong nctype='goods_price'>" + dataRow["StandPrice"].ToDecimal2() + "</strong>元</dd></dl>";
                this.PriceName = Language.Get("Shop/Product/ProductPrice1");
                if (flag2)
                {
                    this.ShoppingCartImage.Visible = false;
                }
                this.Price = Convert.ToDecimal(dataRow["StandPrice"].ToString());
                break;
            case 2:
                {
                    this.ltrAuctionMall.Visible = true;
                    decimal num = dataRow["AuctionStartPrice"].ToDecimal2();
                    decimal num2 = dataRow["CurrentPrice"].ToDecimal2();
                    decimal num3 = Convert.ToDecimal(dataRow["StandPrice"].ToString());
                    string text = "";
                    this.ltrAuctionMall.Text = string.Concat(new object[]
			{
				text,
				"<dl class='nc-detail-price'><dt>当&nbsp;前&nbsp;价：</dt><dd><strong nctype='goods_price'>",
				num3,
				"</strong>元 &nbsp;-&nbsp; 加价幅度：<strong nctype='goods_price'>",
				dataRow["ImcrementPrice"].ToDecimal2(),
				"</strong>元</dd></dl>"
			});
                    this.PriceName = Language.Get("Shop/Product/ProductPrice2");
                    this.ShoppingCartImage.Visible = false;
                    this.Price = num3;
                    break;
                }
            case 3:
                {
                    int num4 = int.Parse(dataRow["TeamNum"].ToString());
                    decimal num5 = 0m;
                    decimal num6 = decimal.Parse(dataRow["StandPrice"].ToString());
                    string text2 = "";
                    string text3 = dataRow["TeamName"].ToString();
                    decimal num9;
                    if (!string.IsNullOrEmpty(text3))
                    {
                        string[] array = text3.Split(new char[]
				{
					','
				});
                        if (array.Length >= num4)
                        {
                            for (int i = 1; i <= num4; i++)
                            {
                                decimal num7 = Convert.ToDecimal(dataRow["TeamPrice" + i]);
                                int num8 = Convert.ToInt32(dataRow["TeamNumber" + i]);
                                num9 = num6 - num7;
                                string str = string.Concat(new object[]
						{
							"<dl class='nc-detail-price'><dt>",
							array[i - 1],
							"：</dt><dd><strong nctype='goods_price'  style='font-size:13px;'>￥",
							num7,
							"</strong><b>&nbsp;&nbsp;至少",
							num8,
							this.PUnit,
							"&nbsp;&nbsp;节省￥",
							num9,
							"</b></dd></dl>"
						});
                                text2 += str;
                            }
                        }
                    }
                    switch (num4)
                    {
                        case 1:
                            num5 = decimal.Parse(dataRow["TeamPrice1"].ToString());
                            break;
                        case 2:
                            num5 = decimal.Parse(dataRow["TeamPrice2"].ToString());
                            break;
                        case 3:
                            num5 = decimal.Parse(dataRow["TeamPrice3"].ToString());
                            break;
                        case 4:
                            num5 = decimal.Parse(dataRow["TeamPrice4"].ToString());
                            break;
                        case 5:
                            num5 = decimal.Parse(dataRow["TeamPrice5"].ToString());
                            break;
                    }
                    decimal num10 = Math.Round(num5 / num6 * 10m, 2);
                    num9 = num6 - num5;
                    this.CustomPriceDIV.Visible = false;
                    this.ltrTuan.Visible = true;
                    string text4 = "";
                    string text5 = "";
                    if (this.EndDate > now)
                    {
                        if (dateTime > now)
                        {
                            text4 = "<dl class='nc-detail-price'><dt>开始时间：</dt><dd><strong nctype='goods_price'>" + dateTime.ToString() + "</strong></dd></dl>";
                        }
                        else
                        {
                            if (dateTime < now)
                            {
                                text5 = "<dl class='nc-detail-price'><dt>&nbsp;</dt><dd><b>结束时间：" + this.EndDate.ToString() + "</b></dd></dl>";
                            }
                        }
                    }
                    else
                    {
                        this.BuyImage.Visible = false;
                        text4 = "<dl class='nc-detail-price'><dt>团购时间：</dt><dd><strong nctype='goods_price'>已结束</strong></dd></dl>";
                    }
                    string text6 = string.Concat(new object[]
			{
				"<dl class='nc-detail-price'><dt>&nbsp;</dt><dd><b>已售：</b><strong>",
				this.BuyTimes,
				"</strong>",
				this.PUnit,
				"<br><b>团购数量有限，下单要快哟<b></dd></dl>",
				text5,
				"<br>"
			});
                    this.ShoppingCartImage.Visible = false;
                    this.ltrTuan.Text = string.Concat(new object[]
			{
				"<dl class='nc-detail-price'><dt>原价：</dt><dd><strong nctype='goods_price' class='delline'>",
				num6,
				"</strong>元</dd></dl>",
				text2,
				text4
			});
                    if (this.Stocks != "0")
                    {
                        this.ltrTuanExplain.Text = text6;
                    }
                    this.Price = num6;
                    break;
                }
            case 4:
                {
                    this.ltrPromote.Visible = true;
                    string text7 = "";
                    if (this.EndDate > now)
                    {
                        if (dateTime > now)
                        {
                            text7 = "<dl class='nc-detail-price'><dt>开始时间：</dt><dd><strong nctype='goods_price'>" + dateTime.ToString() + "</strong></dd></dl>";
                        }
                        else
                        {
                            if (dateTime < now)
                            {
                                text7 = text7 + "<dl class='nc-detail-price'><dt>结束时间：</dt><dd><strong nctype='goods_price'>" + this.EndDate.ToString() + "</strong></dd></dl>";
                            }
                        }
                    }
                    else
                    {
                        this.BuyImage.Visible = false;
                        text7 = "<dl class='nc-detail-price'><dt>促销时间：</dt><dd><strong nctype='goods_price'>已结束</strong></dd></dl>";
                    }
                    this.ltrPromote.Text = string.Concat(new object[]
			{
				"<dl class='nc-detail-price'><dt>原价：</dt><dd><strong nctype='goods_price' class='delline'>",
				dataRow["CurrentPrice"].ToDecimal2(),
				"</strong>元</dd></dl><dl class='nc-detail-price'><dt>促销价：</dt><dd><strong nctype='goods_price'>",
				dataRow["StandPrice"].ToDecimal2(),
				"</strong>元</dd></dl>",
				text7
			});
                    this.PriceName = Language.Get("Shop/Product/ProductPrice4");
                    this.ShoppingCartImage.Visible = false;
                    this.Price = Convert.ToDecimal(dataRow["CurrentPrice"].ToString());
                    break;
                }
            case 5:
                {
                    this.ltrNeedPresentExp.Visible = true;
                    decimal num11 = dataRow["StandPrice"].ToDecimal2();
                    string text8 = dataRow["NeedPresentExp"].ToString();
                    this.ltrNeedPresentExp.Text = string.Concat(new object[]
			{
				"<dl ctype='market' class='nc-detail-price'><dt>价格：</dt><dd><strong nctype='goods_price'>",
				num11,
				"</strong>元</dd></dl><dl ctype='market' class='nc-detail-price'><dt>换购积分：</dt><dd><strong nctype='goods_price'>",
				text8,
				"</strong>分</dd></dl>"
			});
                    this.hfNeedPresentExp.Value = text8;
                    this.BuyImage.Visible = false;
                    this.ShoppingCartImage.Visible = false;
                    if (!string.IsNullOrEmpty(this.hfStocks.Value))
                    {
                        if (Convert.ToInt32(this.hfStocks.Value) > 0)
                        {
                            this.btnNeedPresentExp.Visible = true;
                        }
                    }
                    this.Price = num11;
                    break;
                }
        }
        if (this.SalerID > 0)
        {
            UserInfoBll userInfoBll = new UserInfoBll(this.conn);
            DataTable userInfoByUserID = userInfoBll.GetUserInfoByUserID(this.SalerID);
            DataTable qQTaobaoByUserID = userInfoBll.GetQQTaobaoByUserID(this.SalerID);
            this.ltrSaleCrediet.Text = this.m_shop_product.BindSaleCrediet(this.SalerID).ToString();
            if (userInfoByUserID.Rows.Count > 0)
            {
                this.MobilePhone = userInfoByUserID.Rows[0]["MobilePhone"].ToString();
                this.SalerName = userInfoByUserID.Rows[0]["UserName"].ToString();
                this.HiddenField1.Value = this.SalerName;
                this.RegTime = DateTime.Parse(userInfoByUserID.Rows[0]["RegTime"].ToString());
                this.Taobaowangwang = userInfoByUserID.Rows[0]["Taobaowangwang"].ToString();
                this.OICQ = userInfoByUserID.Rows[0]["OICQ"].ToString();
            }
        }
        else
        {
            this.WriteErrMsg("", Language.GetMemberMsg("Common/EditFail", new string[]
			{
				""
			}), "");
        }
        TimeSpan timeSpan = DateTime.Now.Subtract(dateTime);
        if (this.EnableSale == "false")
        {
            this.WriteErrMsg("", Language.Get("Shop/Product/EnableSale"), "/ProductList.aspx");
        }
        if (this.LeftTime < 0)
        {
            this.LeftTime = 0;
        }
        if (this.Stocks == "0")
        {
            this.LeftTime = 0;
            this.BuyImage.Visible = false;
            this.ShoppingCartImage.Visible = false;
            this.quantity.Disabled = true;
        }
        if (this.LeftTime == 0 && this.AutoPostBack == "True")
        {
            this.LeftTime = this.m_shop_product.UpdateAutoPostBack(this.ProductID);
        }
        this.TeamBuyPrice = new StringBuilder();
        this.AuctionPrice = new StringBuilder();
        this.TeamBuyList = new StringBuilder();
        string str2 = Language.Get("Shop/PayType/payTypeName1");
        if (this.PayType != "")
        {
            Shop_PayType shop_PayType = new Shop_PayType(this.conn);
            DataTable payTypeByUserIDTypeID = shop_PayType.GetPayTypeByUserIDTypeID(this.SalerID, this.PayType.Replace('|', ','));
            if (payTypeByUserIDTypeID.Rows.Count > 0)
            {
                StringBuilder stringBuilder = new StringBuilder();
                for (int j = 0; j < payTypeByUserIDTypeID.Rows.Count; j++)
                {
                    stringBuilder.Append(string.Concat(new string[]
					{
						"&nbsp;/&nbsp;<a href='javascript:void(0)' title='",
						payTypeByUserIDTypeID.Rows[j]["Intro"].ToString(),
						"'>",
						payTypeByUserIDTypeID.Rows[j]["TypeName"].ToString(),
						"</a>"
					}));
                }
                str2 += stringBuilder.ToString();
            }
        }
        string text9 = "";
        if ("0" == this.DeliverPayType)
        {
            this.showDeliverPayTypeDetail = Language.Get("Shop/Deliver/DeliverPayType/Type0") + "<script type='text/javascript'> var deliver_area=new Array();</script>";
            this.Deliver = "none";
        }
        else
        {
            text9 = Language.Get("Shop/Deliver/To") + "&nbsp;<a href='javascript:void(0)' onmouseover='ShowArea(this);'><b id='top_select_area'>" + Language.Get("Shop/Deliver/All") + "</b></a><em id='deliver_top_list'></em>";
            string text10 = dataRow["DeliverType"].ToString();
            if (Text.IsNumber(text10))
            {
                Shop_DeliverType shop_DeliverType = new Shop_DeliverType();
                this.showDeliverPayTypeDetail = shop_DeliverType.GetAuctionDeliverByUserIDTypeID(this.SalerID, int.Parse(text10)) + Environment.NewLine;
                this.showDeliverPayTypeDetail = this.showDeliverPayTypeDetail + "<script type='text/javascript'>setAreaPrice('" + Language.Get("Shop/Deliver/DeliverPayType/All") + "');</script>";
                this.Deliver = "block";
            }
            else
            {
                this.showDeliverPayTypeDetail = Language.Get("Shop/Product/NoDeliverType") + "<script type='text/javascript'> var deliver_area=new Array();</script>";
                this.Deliver = "none";
            }
        }
        this.ltrDeliverPay.Text = text9;
        DataSet dataSet = this.conn.GetDataSet("select * from HLShop_ProductImg where ProductID=" + this.ProductID);
        string text11 = "";
        if (dataSet.Tables[0].Rows.Count > 0)
        {
            DataRow dataRow2 = dataSet.Tables[0].Rows[0];
            if (dataRow2["ImgPath1"].ToString() != "" && dataRow2["ImgPath1"] != null)
            {
                text11 += dataRow2["ImgPath1"].ToString();
            }
            if (dataRow2["ImgPath2"].ToString() != "" && dataRow2["ImgPath2"] != null)
            {
                text11 = text11 + "ξ" + dataRow2["ImgPath2"].ToString();
            }
            if (dataRow2["ImgPath3"].ToString() != "" && dataRow2["ImgPath3"] != null)
            {
                text11 = text11 + "ξ" + dataRow2["ImgPath3"].ToString();
            }
            if (dataRow2["ImgPath4"].ToString() != "" && dataRow2["ImgPath4"] != null)
            {
                text11 = text11 + "ξ" + dataRow2["ImgPath4"].ToString();
            }
            if (dataRow2["ImgPath5"].ToString() != "" && dataRow2["ImgPath5"] != null)
            {
                text11 = text11 + "ξ" + dataRow2["ImgPath5"].ToString();
            }
        }
        string[] array2 = text11.Split(new char[]
		{
			'ξ'
		});
        string text12 = "";
        if (array2[0].ToString() != "" && array2[0] != null)
        {
            if (array2[0].ToString()[0] == '/')
            {
                text12 = array2[0].ToString().Substring(1);
            }
            else
            {
                text12 = array2[0].ToString().Substring(0);
            }
        }
        this.SmallImageUrl = text12;
        StringBuilder stringBuilder2 = new StringBuilder();
        bool flag3 = true;
        for (int j = 0; j < array2.Length; j++)
        {
            if (array2[j] != "" && array2[j] != null)
            {
                stringBuilder2.Append(string.Concat(new string[]
				{
					" <li><a href='",
					(array2[j][0] == '/') ? array2[j].Substring(1) : array2[j],
					"' class='nc-zoom-gallery ",
					flag3 ? "hovered" : "",
					"'  rel=\"useZoom: 'zoom1', smallImage: '",
					(array2[j][0] == '/') ? array2[j].Substring(1) : array2[j],
					"'\"><span class='thumb size40' ><i></i><img src='",
					(array2[j][0] == '/') ? array2[j].Substring(1) : array2[j],
					"' alt='' onload='javascript:DrawImage(this,40,40);' style='height:40px;width:39px;' /></span><b></b></a></li>"
				}));
                flag3 = false;
            }
        }
        this.ltrSmallPicCollection.Text = stringBuilder2.ToString();
        if (array2.Length > 0)
        {
            this.BigImg.ImageUrl = text12;
            this.ChangeBigImg = text12;
            this.wish_pro_img.Src = text12;
        }
        else
        {
            this.BigImg.ImageUrl = "~/Skin/ShowProductStyle/images/nopicture.gif";
            this.ChangeBigImg = "Skin/ShowProductStyle/images/nopicture.gif";
            this.wish_pro_img.Src = "Skin/ShowProductStyle/images/nopicture.gif";
        }
        string productStandard = this.ProductStandard;
        if (productStandard != null)
        {
            if (!(productStandard == "0"))
            {
                if (!(productStandard == "1"))
                {
                    if (productStandard == "2")
                    {
                        this.ltrProType.Text = Language.Get("Shop/Product/ProductStandard2");
                    }
                }
                else
                {
                    this.ltrProType.Text = Language.Get("Shop/Product/ProductStandard1");
                }
            }
            else
            {
                this.ltrProType.Text = Language.Get("Shop/Product/ProductStandard0");
            }
        }
        Shop_Shop shop_Shop = new Shop_Shop();
        if (shop_Shop.GetShopIDByShopOwerID(this.SalerID) <= 0)
        {
        }
        if (!(this.AuctionPrice.ToString() != "") || !(this.TeamBuyPrice.ToString() == ""))
        {
            if (this.AuctionPrice.ToString() == "" && this.TeamBuyPrice.ToString() != "")
            {
            }
        }
        if (dataRow["ProductType"].ToString() == "4")
        {
        }
        this.m_shop_product.UpdateHits(this.ProductID);
        if (base.user != null && base.user.UserID > 0 && base.user.UserID == this.SalerID)
        {
        }
        if (this.ShowProType == "5")
        {
            this.pnlDetailContent.Style["display"] = "none";
            this.pnlContentLeft.Style["display"] = "none";
        }
    }
    private void BingProductAttribute(string attribute)
    {
        if (!string.IsNullOrEmpty(attribute))
        {
            string[] array = attribute.Split(new char[]
			{
				'|'
			});
            string text = "";
            text += "<li><strong>商品属性</strong></li><li></li><li></li>";
            string[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                string str = array2[i];
                text = text + "<li>" + str + "</li>";
            }
            int num = array.Length % 3;
            if (num != 0)
            {
                num = 3 - num;
                for (int j = 0; j < num; j++)
                {
                    text += "<li></li>";
                }
            }
            this.ltrProductAttribute.Text = text;
        }
    }
    private void GetBuyRecord()
    {
        IDbDataParameter[] parameters = new IDbDataParameter[]
		{
			this.conn.CreateParameter("@ProductID", DbType.Int32, this.ProductID),
			this.conn.CreateParameter("@CurrentPage", DbType.Int32, this.ValidateQueString()),
			this.conn.CreateParameter("@PageSize", DbType.Int32, this.EveryPageCount)
		};
        DataTable dataTable = this.conn.GetDataTable(" select top " + this.EveryPageSizeForBuyRecord.ToString() + " *\r\n                                            from HLShop_Order as a\r\n                                            join  HLShop_OrderItem as b\r\n                                            on a.OrderFormID=b.OrderFormID and a.Status=2  \r\n                                            join HLShop_Product as c \r\n                                            on   b.ProductID=c.ProductID and c.ProductID=@ProductID \r\n                                            order by a.InputTime Desc", parameters);
        this.rptBuyRecord.DataSource = dataTable;
        this.rptBuyRecord.DataBind();
        dataTable.Dispose();
    }
    private void SetSelectForComment()
    {
        string text = Fetch.Get("type");
        if (!string.IsNullOrEmpty(text))
        {
            if (text == "1")
            {
                this.GoodComment.Checked = true;
            }
            else
            {
                if (text == "0")
                {
                    this.MiddleComment.Checked = true;
                }
                else
                {
                    if (text == "-1")
                    {
                        this.BadComment.Checked = true;
                    }
                    else
                    {
                        this.AllComment.Checked = true;
                    }
                }
            }
        }
        else
        {
            this.AllComment.Checked = true;
        }
        if (Fetch.Get("hascontent") != string.Empty && Fetch.Get("hascontent") == "1")
        {
            this.cbHasContent.Checked = true;
        }
        else
        {
            this.cbHasContent.Checked = false;
        }
    }
    private void SetCommetnLink()
    {
        int num = 0;
        string text = Fetch.Get("page");
        if (int.TryParse(text, out num))
        {
            if (num > 0 && num <= (this.CommentPageCount + this.EveryPageCount - 1) / this.EveryPageCount)
            {
                this.currentPage.InnerText = text;
            }
            else
            {
                this.currentPage.InnerText = "1";
            }
            if (num <= 1)
            {
                this.LastLink.Attributes.Add("href", string.Concat(new string[]
				{
					"?productid=",
					Fetch.Get("productid"),
					"&type=",
					Fetch.Get("type"),
					"&page=1"
				}));
            }
            else
            {
                this.LastLink.Attributes.Add("href", string.Concat(new string[]
				{
					"?productid=",
					Fetch.Get("productid"),
					"&type=",
					Fetch.Get("type"),
					"&page=",
					(num - 1).ToString()
				}));
            }
            if (num > 0 && num < (this.CommentPageCount + this.EveryPageCount - 1) / this.EveryPageCount)
            {
                this.LastLink.Attributes.Add("href", string.Concat(new string[]
				{
					"?productid=",
					Fetch.Get("productid"),
					"&type=",
					Fetch.Get("type"),
					"&page=",
					(num + 1).ToString()
				}));
            }
            else
            {
                this.LastLink.Attributes.Add("href", string.Concat(new string[]
				{
					"?productid=",
					Fetch.Get("productid"),
					"&type=",
					Fetch.Get("type"),
					"&page=",
					((this.CommentPageCount + this.EveryPageCount - 1) / this.EveryPageCount).ToString()
				}));
            }
        }
        else
        {
            this.currentPage.InnerText = "1";
            this.LastLink.Attributes.Add("href", string.Concat(new string[]
			{
				"?productid=",
				Fetch.Get("productid"),
				"&type=",
				Fetch.Get("type"),
				"&hascontent=",
				Fetch.Get("hascontent"),
				"&page=1"
			}));
            if ((this.CommentPageCount + this.EveryPageCount - 1) / this.EveryPageCount > 1)
            {
                this.LastLink.Attributes.Add("href", string.Concat(new string[]
				{
					"?productid=",
					Fetch.Get("productid"),
					"&type=",
					Fetch.Get("type"),
					"&hascontent=",
					Fetch.Get("hascontent"),
					"&page=",
					(num + 1).ToString()
				}));
            }
            else
            {
                this.LastLink.Attributes.Add("href", string.Concat(new string[]
				{
					"?productid=",
					Fetch.Get("productid"),
					"&type=",
					Fetch.Get("type"),
					"&hascontent=",
					Fetch.Get("hascontent"),
					"&page=1"
				}));
            }
        }
        this.FirstLink.Attributes.Add("href", string.Concat(new string[]
		{
			"?productid=",
			Fetch.Get("productid"),
			"&type=",
			Fetch.Get("type"),
			"&hascontent=",
			Fetch.Get("hascontent"),
			"&page=1"
		}));
        this.EndLink.Attributes.Add("href", string.Concat(new string[]
		{
			"?productid=",
			Fetch.Get("productid"),
			"&type=",
			Fetch.Get("type"),
			"&hascontent=",
			Fetch.Get("hascontent"),
			"&page=",
			((this.CommentPageCount + this.EveryPageCount - 1) / this.EveryPageCount).ToString()
		}));
    }
    public string QueString()
    {
        StringBuilder stringBuilder = new StringBuilder("");
        string text = Fetch.Get("type");
        if (!string.IsNullOrEmpty(text))
        {
            if (text == "1" || text == "0" || text == "-1")
            {
                stringBuilder.Append(" and a.CreditScore=" + text);
            }
        }
        if (Fetch.Get("hascontent") != string.Empty && Fetch.Get("hascontent") == "1")
        {
            stringBuilder.Append(" and a.Comment is not null and a.Comment != '' ");
        }
        return stringBuilder.ToString();
    }
    private int ValidateQueString()
    {
        string text = base.Request.QueryString["page"];
        int num = 1;
        int result;
        if (!string.IsNullOrEmpty(text))
        {
            if (!int.TryParse(text, out num))
            {
                result = 1;
            }
            else
            {
                if (num == 0)
                {
                    result = num + 1;
                }
                else
                {
                    result = num;
                }
            }
        }
        else
        {
            result = 1;
        }
        return result;
    }
    public string GetConntition()
    {
        string text = "productid=" + this.ProductID.ToString();
        if (this.SelectType != "2")
        {
            text = text + "&type=" + this.SelectType;
        }
        if (this.cbHasContent.Checked)
        {
            text += "&hascontent=1";
        }
        else
        {
            text += "&hascontent=0";
        }
        return text;
    }
    public void BindEvaluation()
    {
        IDbDataParameter[] parameters = new IDbDataParameter[]
		{
			this.conn.CreateParameter("@ProductID", DbType.Int32, this.ProductID),
			this.conn.CreateParameter("@SalerID", DbType.Int32, this.SalerID),
			this.conn.CreateParameter("@CurrentPage", DbType.Int32, this.ValidateQueString()),
			this.conn.CreateParameter("@PageSize", DbType.Int32, this.EveryPageCount)
		};
        DataTable dataTable = this.conn.GetDataTable("select * from (\r\n                            select  a.*,d.CM_MyHead,a.CreateTime as sortT,ROW_NUMBER() over(order by a.CreateTime Desc) as number\r\n                            from HLMall_Credit as a \r\n                            join HLShop_OrderItem as b on\r\n                            a.OrderFormNum=b.OrderFormNum and b.ProductID=@ProductID and a.ValuerID<>@SalerID " + this.QueString() + " join HL_UserInfo as d\r\n                            on d.UserID = a.ValuerID\r\n                            join HL_User as c\r\n                            on c.UserID=a.ValuerID and c.IsLocked=0) t\r\n                            where t.number>(@CurrentPage-1)*@PageSize and t.number<=@CurrentPage*@PageSize  ", parameters);
        this.tptProductComment.DataSource = dataTable;
        this.tptProductComment.DataBind();
        dataTable.Dispose();
    }
    protected void BuyImage_Click(object sender, ImageClickEventArgs e)
    {
        this.SecondsKillRepeat();
        string value = this.GuiGeValue.Value;
        if (value != "")
        {
            this.Session["GuiGe"] = value;
        }
        else
        {
            this.Session["GuiGe"] = "";
        }
        if (this.conn.ExecuteCount("select count(*) from HLShop_Product where DateDiff(s,EndDate,getdate())<0 and ProductID=" + this.ProductID) <= 0)
        {
            this.Page.ClientScript.RegisterStartupScript(base.GetType(), "Test", "<script>alert('该商品已到期!');</script>");
        }
        else
        {
            this.Session["newprice"] = "";
            if (this.HiddenField3.Value != "" && this.HiddenField3.Value == "1")
            {
                this.Session["newprice"] = this.HiddenField2.Value;
            }
            this.Session["buyStock"] = this.hfStocks.Value;
            base.Response.Redirect("Buy.aspx?ProductID=" + this.ProductID.ToString() + "&count=" + this.quantity.Value);
        }
    }
    protected void btnNeedPresentExp_Click(object sender, ImageClickEventArgs e)
    {
        base.Response.Redirect("Buy.aspx?ProductID=" + this.ProductID.ToString() + "&count=" + this.quantity.Value);
    }
    protected void SecondsKillRepeat()
    {
    }
    protected void CommentOK_Click(object sender, ImageClickEventArgs e)
    {
    }
    protected string GetUrl()
    {
        string text;
        if (base.Request.ServerVariables["HTTPS"] == "off")
        {
            text = "http://";
        }
        else
        {
            text = "https://";
        }
        text += base.Request.ServerVariables["SERVER_NAME"];
        if (base.Request.ServerVariables["SERVER_PORT"] != "80")
        {
            text = text + ":" + base.Request.ServerVariables["SERVER_PORT"];
        }
        text += base.Request.ServerVariables["URL"];
        if (base.Request.QueryString != null)
        {
            text = text + "?" + base.Request.QueryString;
        }
        return text;
    }
    public void LastLink_Click(object sender, EventArgs e)
    {
        int num = int.Parse(this.CurrentPage);
        if (num > 1)
        {
            base.Response.Redirect("ShowProduct.aspx?" + this.GetConntition() + "&page=" + (num - 1).ToString());
        }
        else
        {
            base.Response.Redirect("ShowProduct.aspx?" + this.GetConntition() + "&page=1");
        }
    }
    public void NextLink_Click(object sender, EventArgs e)
    {
        int num = int.Parse(this.CurrentPage);
        if (num < (this.CommentPageCount + this.EveryPageCount - 1) / this.EveryPageCount)
        {
            base.Response.Redirect("ShowProduct.aspx?" + this.GetConntition() + "&page=" + (num + 1).ToString());
        }
        else
        {
            if (num == 0)
            {
                base.Response.Redirect("ShowProduct.aspx?" + this.GetConntition() + "&page=1");
            }
            else
            {
                base.Response.Redirect("ShowProduct.aspx?" + this.GetConntition() + "&page=" + ((this.CommentPageCount + this.EveryPageCount - 1) / this.EveryPageCount).ToString());
            }
        }
    }
    protected void AllComment_CheckedChanged(object sender, EventArgs e)
    {
        this.PageRedirect("2");
    }
    protected void GoodComment_CheckedChanged(object sender, EventArgs e)
    {
        this.PageRedirect("1");
    }
    protected void MiddleComment_CheckedChanged(object sender, EventArgs e)
    {
        this.PageRedirect("0");
    }
    protected void BadComment_CheckedChanged(object sender, EventArgs e)
    {
        this.PageRedirect("-1");
    }
    private void PageRedirect(string type)
    {
        base.Response.Redirect(string.Concat(new string[]
		{
			"ShowProduct.aspx?productid=",
			this.ProductID.ToString(),
			"&type=",
			type,
			this.cbHasContent.Checked ? "&hascontent=1" : "&hascontent=0",
			"&page=1"
		}));
    }
    protected void cbHasContent_CheckedChanged(object sender, EventArgs e)
    {
        base.Response.Redirect(string.Concat(new string[]
		{
			"ShowProduct.aspx?productid=",
			this.ProductID.ToString(),
			"&type=",
			this.SelectType,
			this.cbHasContent.Checked ? "&hascontent=1" : "&hascontent=0",
			"&page=1"
		}));
    }
    protected void ShoppingCartImage_Click(object sender, ImageClickEventArgs e)
    {
        string value = this.HiddenField3.Value;
        this.Session["shoppingPrice"] = "";
        if (value == "1")
        {
            this.Session["shoppingPrice"] = this.HiddenField2.Value;
        }
        this.Session["shoppingStock"] = this.hfStocks.Value;
        this.SecondsKillRepeat();
        Shop_Product shop_Product = new Shop_Product();
        string value2 = this.GuiGeValue.Value;
        if (value2 != "")
        {
            this.Session["GuiGe"] = value2;
            shop_Product.EditFieldProduct(this.ProductID, value2, "ShoppingCarGuige");
        }
        else
        {
            this.Session["GuiGe"] = "";
        }
        string text = this.HiddenField4.Value;
        if (text != "")
        {
            if (text[text.Length - 1] == ',')
            {
                text = text.Substring(0, text.Length - 1);
            }
            this.Session["GuiGeID"] = text;
        }
        else
        {
            this.Session["GuiGeID"] = "";
        }
        int num = shop_Product.UpdateJustProductID(this.ProductID, 0);
        base.Response.Redirect("ShoppingCart.aspx?ProductID=" + this.ProductID.ToString() + "&count=" + this.quantity.Value);
    }
    public string GetShopImg(object obj)
    {
        string result;
        if (!string.IsNullOrEmpty(obj.ToString()))
        {
            result = obj.ToString();
        }
        else
        {
            result = "Skin/ShowProductStyle/images/default_store_logo.gif";
        }
        return result;
    }
    public void ShowTopShopInfo(int ShopID)
    {
        string sql = "select * from HLShop_Shop,HL_ShopGroup where ShopGroupID=ID and ShopID=" + ShopID;
        DataTable dataTable = this.conn.GetDataTable(sql);
        if (dataTable != null && dataTable.Rows.Count > 0)
        {
            this.SalerID = int.Parse(dataTable.Rows[0]["ShopOwnerID"].ToString());
            this.Hiddendianbiao.Value = dataTable.Rows[0]["ShopImageUrl"].ToString();
            this.HiddenBackGroundImage.Value = dataTable.Rows[0]["BackgroundImage"].ToString();
            this.HiddenShopTitle.Value = dataTable.Rows[0]["ShopName"].ToString();
            this.HiddenShowType.Value = dataTable.Rows[0]["ShowType"].ToString();
            bool flag = false;
            if (dataTable.Rows[0]["Power"] != DBNull.Value)
            {
                string text = dataTable.Rows[0]["Power"].ToString();
                string[] array = text.Split(new char[]
				{
					','
				});
                for (int i = 0; i < array.Length; i++)
                {
                    if (array[i] == "showShopInfo")
                    {
                        flag = true;
                    }
                }
            }
            this.ShowShopInfoPower = flag;
            if (flag)
            {
                this.pnlTopOld.Visible = false;
                this.pnlTopNew.Visible = true;
            }
            else
            {
                this.pnlTopOld.Visible = true;
                this.pnlTopNew.Visible = false;
            }
        }
        dataTable.Dispose();
    }
    public string ShowReplyMessage(string replyId)
    {
        string text = "";
        string sql = string.Concat(new object[]
		{
			"select * from HLShop_Message where M_ProductID=",
			this.ProductID,
			" and M_UserType='saler' and M_ReplayID=",
			replyId
		});
        DataTable dataTable = this.conn.GetDataTable(sql);
        if (dataTable.Rows.Count > 0)
        {
            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                text += "<dl class='ask' style='margin-left:40px;'><dt>回复内容：</dt>";
                string text2 = "";
                string text3 = "";
                string text4 = "";
                if (dataTable.Rows[i]["M_SenderName"] != DBNull.Value)
                {
                    text2 = dataTable.Rows[i]["M_SenderName"].ToString();
                }
                if (dataTable.Rows[i]["M_DateTime"] != DBNull.Value)
                {
                    text3 = dataTable.Rows[i]["M_DateTime"].ToString();
                }
                if (dataTable.Rows[i]["M_Content"] != DBNull.Value)
                {
                    text4 = dataTable.Rows[i]["M_Content"].ToString();
                }
                string text5 = text4;
                int num = text4.IndexOf("------------------------------------------");
                if (num > 0)
                {
                    text5 = text5.Substring(0, num);
                }
                string text6 = string.Concat(new string[]
				{
					"<time datetime=",
					text3,
					" pubdate='pubdate'>[",
					text3,
					"]</time>"
				});
                string text7 = text;
                text = string.Concat(new string[]
				{
					text7,
					"<dd><p>",
					text5,
					"</p><span class='mr10'><span title='dqw'>",
					text2,
					"</span></span>",
					text6
				});
                text += "</dl>";
            }
        }
        return text;
    }
    protected void OutStockImage_Click(object sender, ImageClickEventArgs e)
    {
        if (this.conn.ExecuteCount("select count(*) from HLShop_Product where DateDiff(s,EndDate,getdate())<0 and ProductID=" + this.ProductID) <= 0)
        {
            this.Page.ClientScript.RegisterStartupScript(base.GetType(), "Test", "<script>alert('该商品已到期!');</script>");
        }
        else
        {
            base.Response.Redirect("ShopOutStockLogAdd.aspx?ProductID=" + this.ProductID.ToString());
        }
    }
    protected void OutStockPower(int dianpuID)
    {
        if (base.user.UserID > 0)
        {
            string sql = "select GroupPower,ShopOwnerID from HL_User,HL_Group,HLShop_Shop where HL_User.GroupID=HL_Group.GroupID and HL_User.UserID=ShopOwnerID and HLShop_Shop.ShopID=" + dianpuID;
            DataTable dataTable = this.conn.GetDataTable(sql);
            bool flag = false;
            int num = 0;
            if (dataTable != null && dataTable.Rows.Count > 0)
            {
                string text = "";
                if (dataTable.Rows[0]["GroupPower"] != DBNull.Value)
                {
                    text = dataTable.Rows[0]["GroupPower"].ToString();
                }
                if (dataTable.Rows[0]["ShopOwnerID"] != DBNull.Value)
                {
                    num = Convert.ToInt32(dataTable.Rows[0]["ShopOwnerID"].ToString());
                }
                if (num > 0 && num != base.user.UserID)
                {
                    if (!string.IsNullOrEmpty(text))
                    {
                        string[] array = text.Split(new char[]
						{
							','
						});
                        for (int i = 0; i < array.Length; i++)
                        {
                            if (array[i] == "stockmanage")
                            {
                                flag = true;
                                break;
                            }
                        }
                    }
                }
            }
            if (flag)
            {
                if (this.hfStocks.Value != "")
                {
                    if (Convert.ToInt32(this.hfStocks.Value) <= 0)
                    {
                        if (this.HiddenField3.Value != "" && this.HiddenField3.Value == "1")
                        {
                            this.OutStockImage.Visible = true;
                            this.quantity.Disabled = true;
                        }
                    }
                }
            }
        }
    }
}
